Minjeong / 6월 1주차 / 3문제 #219
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🌱WIL
🚀주간 목표 문제 수: 3개
프로그래머스 #42627. 디스크 컨트롤러: 힙 / Level 3
정리한 링크: (바로가기)
🚩플로우 (선택)
jobs를 요청 시각 기준으로 정렬한다.end_time)을 갱신하고, 반환 시간을 누적한다.end_time = jobs[i][0]).🚩제출한 코드
💡TIL
시간 흐름에 따른 요청 → 처리 → 대기라는 순환 로직을 실제 운영체제의 스케줄링처럼 구현해야 했다.
처음엔 무작정 heap에 넣고 정렬해서 처리하면 될 거라 생각했지만,
시간 조건을 반영하지 않으면 전혀 다른 결과가 나올 수 있다는 걸 배웠다. 나중에 자바로도 풀이해봐야겠다.
또 오랜만에 힙 유형을 풀면서 heapq를 파이썬에서 적용하는 방법에 대해서도 알게 되었다.
https://docs.python.org/ko/3.13/library/heapq.html
https://velog.io/@plate0113/Python-%EC%9A%B0%EC%84%A0%EC%88%9C%EC%9C%84-%ED%81%90-heapq
https://lucky516.tistory.com/5
백준 #14698. 전생했더니 슬라임 연구자였던 건에 대하여 (Hard): 힙 / 골드4
정리한 링크: (바로가기)
🚩플로우 (선택)
T만큼 반복한다.N과 슬라임 에너지 리스트를 입력받는다.🚩제출한 코드
💡TIL
heapq모듈을 쓸 때 리스트를 힙으로 변환하지 않고heappop()을 사용했기 때문이다.heapq는 리스트가 힙 구조일 때만 최소값을 보장하므로heapify()를 반드시 해줘야 한다.heapq를 사용할 때는 반드시heapify()를 먼저 해주자!백준 #1715. 카드 정렬하기: 힙 / 골드4
정리한 링크: (바로가기)
🚩플로우 (선택)
🚩제출한 코드
💡TIL